import java.util.Scanner;

public class D899 {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()) {
			String input = sc.nextLine();
			String spInput[] = input.split(" ");
			int a = Integer.parseInt(spInput[0]);
			int b = Integer.parseInt(spInput[1]);
			int twosCount = 0;			
			
			for(int i = a; i <= b; i++) {
				char charsInput[] = Integer.toString(i).toCharArray();
				for(char c : charsInput)  {
					if(c == '2')
						{ twosCount++; }
				}
			}
			
			System.out.println(Integer.toString(twosCount));
		} // hasNext
	} // main
}